package Offer;

import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

public class p50第一个只出现一次的字符 {
    class Solution {
        public char firstUniqChar(String s) {
            LinkedHashMap<Character, Integer> map = new LinkedHashMap<>();
            for (int i = 0; i < s.length(); i++) {
                map.put(s.charAt(i), map.getOrDefault(s.charAt(i), 0) + 1);
            }
            for (Character character : map.keySet()) {
                if (map.get(character) == 1){
                    return character;
                }
            }
            return ' ';
        }
    }
}
